<?php
/*This details sites and parts of the website that can be accesssed without a username
or password.*/

class Open extends Controller {
	
	function index()
	{
		$this->load->helper(array('form','url'));
		$this->load->library('form_validation');
		
		$formRules = array(
			array(
				'field' => 'username',
				'label' => 'Username',
				'rules' => 'trim|required|alpha_numeric|xss_clean'
				),
			array(
				'field' => 'password',
				'label' => 'Password',
				'rules' => 'trim|required|xss_clean|'
				)
			);
			
		$data['title'] = "Farm101";
		$data['NoName'] = "Don't have a username or password?  This is in Private mode right now, when it opens up please come back to sign up.
		<br /><br />
		Please go <a href='/index.php/open/register/'>here</a> to register.
		";
		$data['heading'] = "<h2 class='centertext'>Login</h2>";
		
		$this->load->view('openheader', $data);
		$this->load->view('openview', $data);
		
		$this->load->database();

		
	}
	
	function register()
	{
		$data['title'] = "Register - Farm101";
		$data['NoName'] = "You may only register if you have a Registration Code.";
		$data['heading'] = "<h2 class='centertext'>Register</h2>";
		$data['formErrorWidth'] = "style='width:205px'";
		$data['wrapperErrorWidth'] = "style='width:500px'";
		
		
		
		
		$this->load->helper(array('form','url'));
		$this->load->library('form_validation');
		
		//Everything here should be moved to a new place, methinks
		
		$formRules = array(
			array(
				'field' => 'username',
				'label' => 'Username',
				'rules' => 'trim|required|min_length[5]|max_length[15]|alpha_numeric|xss_clean'
				),
			array(
				'field' => 'password',
				'label' => 'Password',
				'rules' => 'trim|required|min_length[5]|matches[password2]|xss_clean|'
				),
			array(
				'field' => 'password2',
				'label' => 'Password Confirmation',
				'rules' => 'trim|required|xss_clean|'
				),
			array(
				'field' => 'email',
				'label' => 'Email',
				'rules' => 'trim|required|valid_email|xss_clean'
				),
			array(
				'field' => 'regcode',
				'label' => 'Registration Code',
				'rules' => 'trim|required|xss_clean'
				)
			);
		
		
		$this->form_validation->set_rules($formRules);

		
		if ($this->form_validation->run() == FALSE)
		{
			$this->load->view('openheader', $data);
			$this->load->view('registerSecond', $data);
		}
		else
		{
			$this->load->view('formsuccess');
		}

		
		
		
		
	}
	
	
}



?>